<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 
        await只能得到Promise--resolved状态的结果,作用相当于then函数
         */
        (async ()=>{
            var p = Promise.reject(100);
            var res = await p;
            console.log(res)

        })();
        /* Promise.reject(err).catch()捕获异常 */
    </script>
    <!-- 结合try和catch来获取reject状态的值 -->
    <script>
        (async ()=>{
            var p = Promise.reject("err");
            try{
                let res = await p;
                console.log(res)
            }catch(err){
                console.log(err)
            }
        })();
        /* 
        在async-await中可以使用try-catch语句去捕获异常
        Promise.reject("err").catch()
        */
    </script>

</body>
</html>